package vr;

import java.util.Vector;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class Participant {

	public int bib;
	public String name = null;
	private DateTimeFormatter sdf = DateTimeFormat.forPattern("DD+HH:mm");
//	public DateTime dateStart;
//	public DateTime dateGylleneUttern;
//	public DateTime dateBankeryd;
//	public DateTime dateHjo;
//	public DateTime dateAspa;
//	public DateTime dateMedevi;
//	public DateTime dateMotala;
	public Vector<DateTime> timestamp = new Vector<>();

	String checkedPrint(DateTime d) {
		if (d == null) {
			return "";
		} else {
			return sdf.print(d);
		}
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("<participant>" + System.lineSeparator());
		sb.append("  <bib>" + bib + "</bib>" + System.lineSeparator());
		sb.append("  <name>" + name + "</name>" + System.lineSeparator());

//		sb.append("  <start>" + checkedPrint(dateStart) + "</start>"
//				+ System.lineSeparator());
//		sb.append("  <gylleneuttern>" + checkedPrint(dateGylleneUttern)
//				+ "</gylleneuttern>" + System.lineSeparator());
//		sb.append("  <bankeryd>" + checkedPrint(dateBankeryd) + "</bankeryd>"
//				+ System.lineSeparator());
//		sb.append("  <hjo>" + checkedPrint(dateHjo) + "</hjo>"
//				+ System.lineSeparator());
//		sb.append("  <aspa>" + checkedPrint(dateAspa) + "</aspa>"
//				+ System.lineSeparator());
//		sb.append("  <medevi>" + checkedPrint(dateMedevi) + "</medevi>"
//				+ System.lineSeparator());
//		sb.append("  <motala>" + checkedPrint(dateMotala) + "</motala>"
//				+ System.lineSeparator());

		sb.append("  <start>" + checkedPrint(timestamp.get(0)) + "</start>"
				+ System.lineSeparator());
		sb.append("  <gylleneuttern>" + checkedPrint(timestamp.get(1))
				+ "</gylleneuttern>" + System.lineSeparator());
		sb.append("  <bankeryd>" + checkedPrint(timestamp.get(2)) + "</bankeryd>"
				+ System.lineSeparator());
		sb.append("  <hjo>" + checkedPrint(timestamp.get(3)) + "</hjo>"
				+ System.lineSeparator());
		sb.append("  <aspa>" + checkedPrint(timestamp.get(4)) + "</aspa>"
				+ System.lineSeparator());
		sb.append("  <medevi>" + checkedPrint(timestamp.get(5)) + "</medevi>"
				+ System.lineSeparator());
		sb.append("  <motala>" + checkedPrint(timestamp.get(6)) + "</motala>"
				+ System.lineSeparator());
		
		sb.append("</participant>" + System.lineSeparator());

		return sb.toString();
	}
}
